<template>
	<view class="pages">
		<view class="item flex flex-column">
			<view class="flex align-center justify-center">
				<view class="title u-m-b-20">
					<u-icon
						name="https://aihelp.oss-cn-hangzhou.aliyuncs.com/public/base/2023/11/10/94ad6246f039451ea1291129f357a3e4.png"
						size="30" class="u-m-r-10"></u-icon>
					可调剂的专业
				</view>
			</view>
			<template v-if="major && major.length">
				<view v-for="(item,index) in major" :key="index">
					<view class="u-m-b-20 u-font-28 bold color333">{{item.name}}</view>
					<view class="u-font-24 color555 desc">
						<text class="u-m-r-20" v-for="(items,indexs) in item.list"
							:key="indexs">{{items.majorCode}}{{items.majorName}}</text>
					</view>
				</view>
			</template>
			<view v-else class="text-center">无</view>
		</view>
		<view class="item flex flex-column">
			<view class="flex align-center justify-center">
				<view class="title u-m-b-20">
					<u-icon
						name="https://aihelp.oss-cn-hangzhou.aliyuncs.com/public/base/2023/11/10/94ad6246f039451ea1291129f357a3e4.png"
						size="30" class="u-m-r-10"></u-icon>
					可调剂的大学数量
				</view>
			</view>
			<template>
				<view class="u-m-b-20 u-font-24">
					<view class="u-m-b-15">
						<text class="u-font-28 bold">本专业</text>
						全国共有 <text class="text-warn">{{schoolNum.bzy.schoolTotal || 0}}</text> 个大学接收调剂：
					</view>
					<view class="u-m-b-20">
						其中风险极大的有
						<text class="text-warn">{{schoolNum.bzy.dangerTotal || 0}}</text>
						所，风险预警有
						<text class="text-warn">{{schoolNum.bzy.warningTotal || 0}}</text>
						所，风险提示有
						<text class="text-warn">{{schoolNum.bzy.pirmaryTotal || 0}}</text> 所
					</view>
				</view>
				<view class="u-m-b-20 u-font-24">
					<view class="u-m-b-15">
						<text class="u-font-28 bold">本一级学科</text>
						全国共有 <text class="text-warn">{{schoolNum.byjxk.majorTotal || 0}}</text> 个专业接收调剂，共有 <text
							class="text-warn">{{schoolNum.byjxk.schoolTotal || 0}}</text>所大学接收调剂：
					</view>
					<view class="u-m-b-20">
						其中风险极大的有
						<text class="text-warn">{{schoolNum.byjxk.dangerTotal || 0}}</text>
						所，风险预警有
						<text class="text-warn">{{schoolNum.byjxk.warningTotal || 0}}</text>
						所，风险提示有
						<text class="text-warn">{{schoolNum.byjxk.pirmaryTotal || 0}}</text> 所
					</view>
				</view>
				<!-- <view class="u-m-b-20 u-font-24">
					<view class="u-m-b-15">
						<text class="u-font-28 bold">本学科</text>
						全国共有 <text class="text-warn">15</text> 个专业接收调剂，共有 <text class="text-warn">15</text>所大学接收调剂：
					</view>
					<view class="u-m-b-20">
						其中风险极大的有
						<text class="text-warn">15</text>
						所，风险预警有
						<text class="text-warn">15</text>
						所，风险提示有
						<text class="text-warn">15</text> 所
					</view>
				</view> 
				<view class="u-m-b-20 u-font-24">
					<view class="u-m-b-15">
						<text class="u-font-28 bold">跨学科</text>
						全国共有 <text class="text-warn">15</text> 个专业接收调剂，共有 <text class="text-warn">15</text>所大学接收调剂：
					</view>
					<view class="u-m-b-20">
						其中风险极大的有
						<text class="text-warn">15</text>
						所，风险预警有
						<text class="text-warn">15</text>
						所，风险提示有
						<text class="text-warn">15</text> 所
					</view>
				</view> -->
			</template>
			<!-- <view v-else class="text-center">无</view> -->
		</view>
		<view class="item flex flex-column">
			<view class="flex align-center justify-center">
				<view class="title u-m-b-20">
					<u-icon
						name="https://aihelp.oss-cn-hangzhou.aliyuncs.com/public/base/2023/11/10/94ad6246f039451ea1291129f357a3e4.png"
						size="30" class="u-m-r-10"></u-icon>
					可调剂的省份
				</view>
			</view>
			<template>
				<view class="u-m-b-20 u-font-28 flex align-center">
					<view>A区</view>
					<view class="u-m-l-20">
						<text class="text-warn u-m-r-5 u-m-l-5">{{economize.a.province || 0}}</text>个省
						<text class="text-warn u-m-r-5 u-m-l-5">{{economize.a.school || 0}}</text>所大学
					</view>
				</view>
				<view class="u-m-b-20 u-font-28 flex align-center">
					<view>B区</view>
					<view class="u-m-l-20">
						<text class="text-warn u-m-r-5 u-m-l-5">{{economize.b.province || 0}}</text>个省
						<text class="text-warn u-m-r-5 u-m-l-5">{{economize.b.school || 0}}</text>所大学
					</view>
				</view>
			</template>
		</view>
		<view class="item flex flex-column">
			<view class="flex align-center justify-center">
				<view class="title u-m-b-20">
					<u-icon
						name="https://aihelp.oss-cn-hangzhou.aliyuncs.com/public/base/2023/11/10/94ad6246f039451ea1291129f357a3e4.png"
						size="30" class="u-m-r-10"></u-icon>
					可调剂的专业类别和学习形式类别
				</view>
			</view>
			<template>
				<view class="u-m-b-20 u-font-28 flex align-center">
					<view>
						全日制共
						<text class="text-warn u-m-r-5 u-m-l-5">{{majorCategorie.fullTimeNum || 0}}</text>
						个
					</view>
					<view>
						非全日制共
						<text class="text-warn u-m-r-5 u-m-l-5">{{majorCategorie.partTimeNum || 0}}</text>
						个
					</view>
				</view>
				<view class="u-m-b-20 u-font-28 flex align-center">
					<view>
						学硕共
						<text class="text-warn u-m-r-5 u-m-l-5">{{majorCategorie.mastersDegree || 0}}</text>
						个
					</view>
					<view>
						专硕共
						<text class="text-warn u-m-r-5 u-m-l-5">{{majorCategorie.professionalMasterDegreeNum || 0}}</text>
						个
					</view>
				</view>
				<view class="u-m-b-20 u-font-28 flex align-center">
					<view>
						专项计划共
						<text class="text-warn u-m-r-5 u-m-l-5">{{majorCategorie.planNum || 0}}</text>
						个
					</view>
				</view>
				<view class="u-m-b-20 u-font-28 flex align-center">
					<view>
						定向共
						<text class="text-warn u-m-r-5 u-m-l-5">{{majorCategorie.orientationPlanNum || 0}}</text>
						个
					</view>
				</view>
			</template>
		</view>

		<!-- 按钮 -->
		<view style="height: 300rpx;"></view>
		<view class="btn" @click="back">查看详细列表</view>
	</view>
</template>

<script>
	import {
		regulateList,
	} from "@/api/toolbox.js"
	export default {
		data() {
			return {
				majorCategorie:{},
				economize: {
					a: {

					},
					b: {

					}
				},
				//可调剂的大学数量
				schoolNum: {
					bzy: {}, //本专业
					byjxk: {}, //本一级学科
					bxk: {}, //本学科
					kxk: {}, //跨学科
				},
				//可调剂的专业
				major: [],
				source: {
					collageCode: "023",
					collageName: "哲学系",
					english: "100",
					firstTotal: "400",
					graduationInstitution: "四川大学",
					majorCode: "010101",
					majorFirst: "100",
					majorName: "马克思主义哲学",
					majorSecond: "100",
					name: "张杨旭",
					phone: "17761214940",
					politics: "100",
					province: "1475405387606917120",
					schoolCode: "10001",
					schoolName: "北京大学",
					undergraduatellajor: "哲学",
				}
			}
		},
		onLoad() {
			this.handleNews();
		},
		methods: {
			back(){
				uni.navigateBack(1);
			},
			handleNews() {
				let storeSync = uni.getStorageSync('chooseArr');
				let storeSyncFraction = uni.getStorageSync('fraction');
				let storeSyncInformation = uni.getStorageSync('information');

				if (storeSyncInformation) {
					storeSyncInformation = JSON.parse(storeSyncInformation);
				}
				if (storeSyncFraction) {
					storeSyncFraction = JSON.parse(storeSyncFraction);
				}
				if (storeSync) {
					storeSync = JSON.parse(storeSync);
				}
				this.source = {
					majorCode: storeSync[3].value,
					firstTotal: storeSyncFraction.scroll1
				}
				this.getData();
			},
			getData() {
				uni.showLoading({
					mask: true
				});
				regulateList({
					source: this.source
				}).then(res => {
					if (res.code == 100000) {
						let data = res.data;
						console.warn('ownMajorDetail: ',data.ownMajorDetail);
						if (data.adjustMajors && data.adjustMajors.length) {
							let majorL = [];
							data.adjustMajors.forEach(e => {
								let index = majorL.findIndex(v => v.name === e.subjectOneCode);
								if (index == -1) {
									majorL.push({
										name: e.subjectOneCode,
										list: [{
											majorCode: e.majorCode,
											majorName: e.majorName
										}]
									})
								} else {
									majorL[index].list.push({
										majorCode: e.majorCode,
										majorName: e.majorName
									});
								}
							})
							this.major = majorL;
						}
						this.schoolNum = {
							//本专业
							bzy: {
								schoolTotal: data.ownMajorDetail.schoolWholeNationNum,
								dangerTotal: data.ownMajorDetail.aclassification,
								warningTotal: data.ownMajorDetail.bclassification,
								pirmaryTotal: data.ownMajorDetail.cclassification,
							},
							//本一级学科
							byjxk: {
								schoolTotal: data.ownOneSubjectDetail.schoolMajorWholeNationNum,
								majorTotal: data.ownOneSubjectDetail.schoolWholeNationNum,
								dangerTotal: data.ownMajorDetail.aclassification,
								warningTotal: data.ownMajorDetail.bclassification,
								pirmaryTotal: data.ownMajorDetail.cclassification,
							},
							bxk: {}, //本学科
							kxk: {}, //跨学科
						}
						this.economize = {
							a: {
								province: data.provinceA,
								school: data.provinceASchoolNum
							},
							b: {
								province: data.provinceB,
								school: data.provinceBSchoolNum
							}
						}
						
						this.majorCategorie = data.majorCategorie;
					}
				}).finally(()=>{
					uni.hideLoading();
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.pages {
		background-color: #F6F8F6;
		min-height: 100vh;
		padding-left: 30rpx;
		padding-right: 30rpx;
		padding-top: 20rpx;

		.item {
			margin-bottom: 30rpx;
			background-color: #ffffff;
			border-radius: 8rpx;
			border: 2rpx solid #EBEEEF;
			padding: 30rpx;

			.title {
				padding-left: 36rpx;
				padding-right: 36rpx;
				background-color: rgba(245, 154, 35, 0.2);
				height: 60rpx;
				border-radius: 100rpx;
				color: #F59A23;
				display: flex;
				align-items: center;
				justify-content: center;
			}

			.desc {
				line-height: 2;
			}
		}

		.btn {
			background-color: #F7DD5E;
			position: fixed;
			width: 280rpx;
			height: 90rpx;
			border-radius: 100rpx;
			box-shadow: 8rpx 6rpx 20rpx #666666;
			left: 50%;
			bottom: 200rpx;
			transform: translate(-50%);
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}

	.text-warn {
		color: #F59A23;
	}
</style>